﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Ink;
using System.Media;
using System.Windows.Media.Animation;
using Microsoft.Kinect;
using System.ComponentModel;
using Coding4Fun.Kinect.Wpf;
using Coding4Fun.Kinect.Wpf.Controls;
using System.IO;
using System.Globalization;




namespace KinectBautizo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        //Declarando el objeto sensor de la clase KinectSensor
        KinectSensor sensor;
        

        //Creando método que inicia la ventana que heredó MainWindows

        protected void CargaVentana(object sender, RoutedEventArgs e)
        {
            if (KinectSensor.KinectSensors.Count > 0)
            {
                int deviceCount = KinectSensor.KinectSensors.Count;
                this.sensor = KinectSensor.KinectSensors[0];
                this.sensor.Start();
                this.sensor.ColorStream.Enable();
                this.sensor.DepthStream.Enable();
                this.sensor.SkeletonStream.Enable();
                MessageBox.Show(deviceCount.ToString());
               // MessageBox.Show("hay kinect!");
                ajustar_angulo();
                

                
            }
            else
            {
                MessageBox.Show("No hay kinect!");
                //cierra la ventana, es decir, se ejecutará lo que 
                //en el método
                this.Close();
            }
        
            //comenzemos con la habilitación de los eventos:

            this.Close();
        }

        
        private void ajustar_angulo()
        {
            string angle=this.sensor.MinElevationAngle.ToString();
            MessageBox.Show(angle);
            for (int i = 1; i <= 2; i++)
            {
                this.sensor.ElevationAngle = +10;
                this.sensor.ElevationAngle = -10;
                
            }
            
           
            }


        private void CierraVentana(object sender, CancelEventArgs e)
        {

            if (KinectStatus.Connected.Equals(true))
            {

                //detiene los sensores de profundidad, eskeleto y video, además del de audio
                
                this.sensor.Stop();

                //para apagar el infrarojillo
                sensor.ForceInfraredEmitterOff = true; 
            }
            else
            {
               //luego se me ocurrirá :P
            }
        }

        

       

    }
}
